//
//  Constants.m
//  HongYanNews
//
//  Created by 123 on 14-7-3.
//  Copyright (c) 2014年 iMobile. All rights reserved.
//

#import "Constants.h"
#import "Reachability.h"

@implementation Constants

+(bool)isExistenceNetwork
{
    BOOL isExistenceNetwork = YES;
    //UIAlertView *alert1;//3G提醒
    Reachability *r = [Reachability reachabilityWithHostname:@"www.apple.com"];
    switch ([r currentReachabilityStatus]) {
        case NotReachable:
            NSLog(@"没有网络");
            isExistenceNetwork=NO;
            break;
        case ReachableViaWWAN:
            NSLog(@"正在使用3G网络");
//            alert1 = [[UIAlertView alloc]initWithTitle:@"提示" message:@"您当前正在使用3G网络，请注意您的流量资费或切换至WiFi状态！" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
//            [alert1 show];
            break;
        case ReachableViaWiFi:
            NSLog(@"正在使用wifi网络");
            isExistenceNetwork=YES;
            break;
    }
    if (!isExistenceNetwork) {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"没有网络连接！" message:@"请检查你的网络设置" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alert show];
    }
    return isExistenceNetwork;
}

@end
